﻿using Password_Manager.Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace Password_Manager
{
    public partial class Form1 : Form
    {
        CreateDatabaseAndTables tables = new CreateDatabaseAndTables();
        public Form1()
        {
            InitializeComponent();
            var initializer = new CreateDatabaseAndTables();
            initializer.CreateTable();
            txtAccount.KeyPress += TxtAccount_KeyPress;

        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e) //登录
        {
            string account = txtAccount.Text.Trim(); // 获取账号输入
            string password = txtPassword.Text.Trim(); // 获取密码输入
            this.Hide();
            tables.UserLogin(account,password);

        }

        private void button3_Click(object sender, EventArgs e) //退出
        {
            this.Close();
            this.Dispose();
        }

        private void button2_Click(object sender, EventArgs e) //注册
        {
            Register register = new Register();
            register.ShowDialog(); // 显示注册窗口
        }

        private void txtAccount_TextChanged(object sender, EventArgs e)
        {

        }
        private void TxtAccount_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && e.KeyChar != (char)Keys.Back)
            {
                e.Handled = true; 
            }
        }

      
    }
}
